import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'ui/pages/home_page.dart';
import 'ui/pages/detail_page.dart';
import 'ui/pages/settings_page.dart';

void main() {
  // **特性4: ProviderScope - Riverpod 的入口**
  // 所有的 Provider 状态都存储在这里。
  // 必须用它包裹你的整个应用，通常是 MaterialApp 的父级。
  runApp(const ProviderScope(child: MyApp()));
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Riverpod Demo',
      theme: ThemeData(
        primarySwatch: Colors.teal,
        useMaterial3: true,
        brightness: Brightness.light,
      ),
      // 使用命名路由来解耦页面跳转
      initialRoute: '/',
      routes: {
        '/': (context) => const HomePage(),
        '/detail': (context) => const DetailPage(),
        '/settings': (context) => const SettingsPage(),
      },
    );
  }
}
